
#
# FreeBSD:
#    the system "make" should be fine
#
# Linux:
#    requires "pmake"
#    (this is the pmake package on ubuntu)      
#

version  = 0.01
pkg_file = nsfm-$(version)
uname   != uname

.if $(uname) == FreeBSD
bin = /usr/local/bin
etc = /usr/local/etc
man = /usr/local/man/man1
.else
bin = /usr/bin
etc = /etc
man = /usr/share/man/man1
.endif

default:
	@echo targets:
	@echo "   install (into '$(bin)' and '$(etc)')"
	@echo "   deinstall (or uninstall, or remove)"
	@echo "   reinstall (make deinstall install)"
	@echo "   package"
	@echo "   clean"
	@echo "   update"

install:
	install -vm 0555 python/nsfm $(bin)/nsfm
	install -vm 0555 util/nsfm.hold $(bin)/nsfm.hold
	install -vm 0555 util/nsfm.gterm $(bin)/nsfm.gterm
	install -vm 0444 files/nsfm.rc $(etc)/nsfm.rc.example
	test -e $(etc)/nsfm.rc || install -vm 0444 files/nsfm.rc $(etc)/nsfm.rc
	install -vm 0444 files/nsfm.1 $(man)/nsfm.1


deinstall:
	rm -vf $(bin)/nsfm
	rm -vf $(etc)/nsfm.rc
	rm -vf $(etc)/nsfm.rc.example
	rm -vf $(bin)/nsfm.hold
	rm -vf $(bin)/nsfm.gterm
	rm -vf $(man)/nsfm.1

reinstall:
	$(MAKE) deinstall install

uninstall:
	$(MAKE) deinstall

remove:
	$(MAKE) deinstall

pkg_files  = Makefile
pkg_files += README
pkg_files += python/nsfm
pkg_files += files/nsfm.rc
pkg_files += files/nsfm.1
pkg_files += util/nsfm.hold
pkg_files += util/nsfm.gterm

package:
	rm -fr $(pkg_file)
	mkdir -p $(pkg_file)
	tar cf -  $(pkg_files) | tar xf - -C $(pkg_file)
	tar zcvf $(pkg_file).tgz $(pkg_file)
	rm -r $(pkg_file)
	ls -lh $(pkg_file).tgz

clean:
	rm -vf $(pkg_file).tgz

commit:
	svn commit

update:
	svn update

